import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    //  是否登录
    isLogin: false,
    token: "",
    userInfo: {},
  },
  mutations: {
    ["setToken"](state, token) {
      sessionStorage.setItem("token", token);
      state.token = token;
    },
    ["removeToken"](state, token) {
      sessionStorage.removeItem("token", token);
      state.token = token;
    },
    ["setUserInfo"](state, userInfo) {
      sessionStorage.setItem("userInfo", userInfo);
      state.userInfo = userInfo;
    },
    ["removeUserInfo"](state, userInfo) {
      sessionStorage.removeItem("userInfo", userInfo);
      state.userInfo = userInfo;
    },
  },
  actions: {},
  modules: {},
});
